<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>父子组件的创建</title>
    <script src="./js/vue2.js"></script>
</head>

<body>
    <div id="app">
        <father></father>
        
    </div>
    <template id='father'>
        <div class="father">
            <h1>我是父组件{{fname}}</h1>
            <son></son>
        </div>
    </template>
    <template id='son'>
        <div class="son">
            <h2>我是子组件{{sname}}</h2>
        </div>
    </template>
</body>
<script>
    // 创建父子组件
    Vue.component('father', {
        template: '#father',
        data() {
            return {
                fname: '老豆'
            }
        },
        // 创建子组件
        components:{
            'son':{
                template:'#son',
                data(){
                    return {
                        sname:'儿子'
                    }
                }
            }
        }
    })
    var vm = new Vue({
        el: "#app",
        data: {

        }
    })
</script>

</html>